using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Core
{
    public class HCProject
    {
        private DirectoryInfo _projFolder = null;

        public DirectoryInfo ProjectFolder
        {
            get { return _projFolder; }
            set { _projFolder = value; }
        }

        public string HCId
        {
            get
            {
                //this is the manifest id without the .manifest in the end
                return this.ProjectManifest.id.ToUpper().Replace(".MANIFEST", string.Empty);
            }
        }

        private DirectoryInfo _contentFolder = null;

        public DirectoryInfo ContentFolder
        {
            get { return _contentFolder; }
            set { _contentFolder = value; }
        }

        private DirectoryInfo _metaDataFolder = null;

        public DirectoryInfo MetaDataFolder
        {
            get { return _metaDataFolder; }
            set { _metaDataFolder = value; }
        }

        private HCManifest _projectManifest = null;

        public HCManifest ProjectManifest
        {
            get { return _projectManifest; }
            set { _projectManifest = value; }
        }

        private List<HelpCategory> _helpCategory = new List<HelpCategory>();

        public List<HelpCategory> HelpCategory
        {
            get { return _helpCategory; }
            set { _helpCategory = value; }
        }

        private List<HelpContext> _helpContext = new List<HelpContext>();

        public List<HelpContext> HelpContext
        {
            get { return _helpContext; }
            set { _helpContext = value; }
        }

        private List<HelpCss> _helpCss = new List<HelpCss>();

        public List<HelpCss> HelpCss
        {
            get { return _helpCss; }
            set { _helpCss = value; }
        }

        private List<HelpImage> _helpImage = new List<HelpImage>();

        public List<HelpImage> HelpImage
        {
            get { return _helpImage; }
            set { _helpImage = value; }
        }

        private List<HelpScript> _helpScript = new List<HelpScript>();

        public List<HelpScript> HelpScript
        {
            get { return _helpScript; }
            set { _helpScript = value; }
        }

        private List<HelpTopic> _helpTopic = new List<HelpTopic>();

        public List<HelpTopic> HelpTopic
        {
            get { return _helpTopic; }
            set { _helpTopic = value; }
        }

        private HCHelpMapContainer _helpMapContainer = null;

        public HCHelpMapContainer HelpMapContainer
        {
            get { return _helpMapContainer; }
            set { _helpMapContainer = value; }
        }

        public static int CompareHelpItem(HelpItem left, HelpItem right)
        {
            if (left == null)
            {
                if (right == null)
                { return 0; }
                else { return -1; }
            }
            else
            {
                if (right == null)
                { return 1; }
                else
                {
                    return string.Compare(left.id, right.id, true);
                }
            }
        }

        public void SaveProjectToDisk()
        {
            foreach (HelpCategory cat in this.HelpCategory)
            {
                cat.SaveToDisk();
            }

            foreach (HelpContext con in this.HelpContext)
            {
                con.SaveToDisk();
            }

            foreach (HelpCss css in this.HelpCss)
            {
                css.SaveToDisk();
            }

            foreach (HelpImage img in this.HelpImage)
            {
                img.SaveToDisk();
            }

            foreach (HelpScript script in this.HelpScript)
            {
                script.SaveToDisk();
            }

            foreach (HelpTopic ht in this.HelpTopic)
            {
                ht.SaveToDisk();
            }

            this.ProjectManifest.SaveToDisk();
            if (this.HelpMapContainer != null)
                this.HelpMapContainer.SaveToDisk();
        }
    }
}
